package com.wiloon.java8x.collection;

/**
 * Created with IntelliJ IDEA.
 * User: wiloon
 * Date: 9/22/12
 * Time: 4:02 PM
 */

import java.io.*;
import java.util.*;

public class VectorTest {
    public static void main(String[] args) {
        Vector vector = new Vector();
        System.out.println("enter your number:");
        int i = 0;
        while (true) {
            try {
                i = System.in.read();
            } catch (IOException e) {
            }
            if (i == '\n' || i == '\r')
                break;
            else {
                int num = i - '0';
                vector.addElement(new Integer(num));
            }
        }
        Enumeration en = vector.elements();
        int sum = 0;
        int c = 0;
        while (en.hasMoreElements()) {
            Integer b = (Integer) en.nextElement();
            c = b.intValue();
            System.out.println(c);
            sum = sum + c;
        }
        System.out.println("sum=" + sum);
    }
}